<?php $this->load->view('header');?>

<body class="childrenBody">
    <blockquote class="layui-elem-quote news_search">
		<div>
			<div class="layui-inline">
				<a class="layui-btn layui-btn-custom Add_btn"><i class="layui-icon">&#xe654;</i> 课程卡</a>
			</div>
		</div>
		
	</blockquote>

	<!-- 视图 -->
	<div class="layui-form news_list">
		<form class="layui-form">
			<table class="layui-table" lay-even="" lay-skin="line">
			    <thead>
				<tr>
					<th>名称</th>
					<th>价格（￥）</th>
					<th>次数</th>
					<th>操作</th>
				</tr> 
			    </thead>
				<tbody class="goods_content" id="view">
				<?php if ($card_list):?>	
					<?php foreach ($card_list as $item):?>
					<tr>
					  <td><?=$item['card_name']?></td>
					  <td><?=$item['price']?></td>
					  <td><?=$item['course_num']?></td>
					  <td>
					    <a class="layui-btn layui-btn-warm layui-btn-mini" onclick="_edit(<?=$item['id']?>,<?=$course_id?>);" title="编辑">
					      <i class="layui-icon">&#xe642;</i>编辑
					    </a>
					    <a class="layui-btn layui-btn-danger layui-btn-mini" onclick="_delete(<?=$item['id']?>);" title="删除">
					      <i class="layui-icon">&#xe640;</i>删除
					    </a>
					  </td>
					</tr>
					<?php endforeach;?>
				<?php else:?>
					<tr>
						<td>暂无数据</td>
					</tr>
				<?php endif;?>
				</tbody>
			</table>
		</form>
	</div>

	<script type="text/javascript">
	layui.config({
		version: true
	}).use(['jquery','layer', 'laytpl', 'form', 'element'],function(){
		var layer = parent.layer === undefined ? layui.layer : parent.layer,
			laytpl = layui.laytpl,
			form = layui.form,
			element = layui.element,
			$ = layui.jquery;

			var course_id = <?=$course_id?>;

			//添加
			$('.Add_btn').click(function() 
			{
				var index = layui.layer.open({
					title : "编辑课程卡",
					type : 2,
					maxmin: true,
					area: ['700px', '500px'],
					offset: '30px',
					content : "admin.php/CourseCard/coures_card_info/"+course_id,
					cancel: function(index, layero){ 
						location.reload();						 
					}  
				});
			});
	});


	//编辑
	function _edit(card_id,course_id)
	{
		var index = layui.layer.open({
			title : "编辑课程卡",
			type : 2,
			maxmin: true,
			area: ['700px', '500px'],
			offset: '30px',
			content : "admin.php/CourseCard/coures_card_info/"+course_id+"/"+card_id,
			cancel: function(index, layero){ 
				location.reload();						 
			}  
		});

	}



	//删除
	function _delete(id)
	{
		layer.confirm('确定删除选中的信息？',{icon:3, title:'提示信息'},function(index){
			$.get('admin.php/CourseCard/delete_card',{card_id:id}, function(res) {
				if (res.status == 200) {
					layer.msg(res.message, {icon:1});
					location.reload();
				}
				else
				{
					layer.msg(res.message, {icon:2});
				}
			},"json");
		});
	}


	</script>

</body>
</html>